nums=[1,1,5]
def nextPermutation(nums):
    nums_len=len(nums)
    if nums_len==1:
        print(nums)
        return  None
    l_pointer,r_pointer=nums_len-2,nums_len-1
    while l_pointer>=0:
        if nums[l_pointer]<nums[r_pointer]:
            nums[l_pointer],nums[r_pointer]=nums[r_pointer],nums[l_pointer]
            break
        else:
            l_pointer-=1
            r_pointer-=1
    if l_pointer<0:
        nums.sort()
    print(nums)
nextPermutation(nums)